package com.ibook;

import java.util.Map;
import java.util.Set;

import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.PropertyModel;

/**
 * Homepage
 */
public class HomePage extends WebPage {

	private static final long serialVersionUID = 1L;

	private int count = 0;
	
	private Label label=null;
	
	// TODO Add any page properties or variables here

	/**
	 * Constructor that is invoked when page is invoked without a session.
	 * 
	 * @param parameters
	 *            Page parameters
	 */
	public HomePage(final PageParameters parameters) {

		// Add the simplest type of label
		label = new Label("message",new PropertyModel(this,"count"));
		label.setOutputMarkupId(true);

		
		
		label.add(new SimpleAttributeModifier("style","color:red;"));
		
		
		add(label);
				
		add(new Form("testForm"));
		add(new AjaxFallbackLink("testLink") {

			@Override
			public void onClick(AjaxRequestTarget target) {
				count++;
				if(target!=null){
					target.addComponent(label);
				}
			}
		});
		
		add(new AjaxFallbackLink("testLink2"){

			@Override
			public void onClick(AjaxRequestTarget target) {
				count--;
				if(target!=null){
					target.addComponent(label);
				}
			}
			
		});

	}
}
